package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.EmployeePageQueryDTO;
import com.sky.entity.Employee;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询用户信息
     *
     * @param username 用户名
     * @return 用户对象
     */
    @Select("select * from employee where username = #{username}")
    Employee selectByUsername(String username);

    /**
     * 新增员工
     *
     * @param employee 员工对象
     */
    void add(Employee employee);

    /**
     * 根据id查询员工
     *
     * @param id 员工id
     * @return employee
     */
    @Select("select * from employee where id = #{id}")
    Employee getById(Long id);

    /**
     * 员工动态条件查询
     *
     * @param employeePageQueryDTO dto
     * @return page
     */
    Page<Employee> pageQuery(EmployeePageQueryDTO employeePageQueryDTO);

    /**
     * 根据主键动态修改属性
     *
     * @param employee 员工对象
     */
    void update(Employee employee);

    /**
     * 修改密码
     *
     * @param id          员工id
     * @param newPassword 新密码
     */
    @Update("update employee set password = #{newPassword} where id = #{id}")
    void editPassword(Long id, String newPassword);

}
